package com.gui.hospital.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gui.hospital.mapper.HospitalDepartmentMapper;
import com.gui.hospital.model.HospitalDepartment;
import com.gui.hospital.service.HospitalDepartmentService;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author 言叶
 * Date：2025/9/4
 */
@Service
@AllArgsConstructor
public class HospitalDepartmentServiceImpl
        extends ServiceImpl<HospitalDepartmentMapper, HospitalDepartment>
        implements HospitalDepartmentService {

    private final HospitalDepartmentMapper hospitalDepartmentMapper;

    /*
     * 根据医院id查询部门
     */
    @Override
    public List<HospitalDepartment> findByHospitalId(Integer hospitalId) {
        QueryWrapper<HospitalDepartment> hospitalDepartmentQueryWrapper = new QueryWrapper<>();
        hospitalDepartmentQueryWrapper.lambda().eq(HospitalDepartment::getHospitalId, hospitalId);
        hospitalDepartmentQueryWrapper.lambda().eq(HospitalDepartment::getPid, 0);
        return hospitalDepartmentMapper.selectList(hospitalDepartmentQueryWrapper);
    }
    /*
     * 根据部门id查询子部门
     */
    @Override
    public List<HospitalDepartment> findByPid(Integer pid) {
        QueryWrapper<HospitalDepartment> hospitalDepartmentQueryWrapper = new QueryWrapper<>();
        hospitalDepartmentQueryWrapper.lambda().eq(HospitalDepartment::getPid, pid);
        return hospitalDepartmentMapper.selectList(hospitalDepartmentQueryWrapper);
    }


}
